/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;

/**
 *
 * @author ely
 * 
 * Grupos
 */
@Entity
public class Groups implements Serializable{
    
    @Id
    @SequenceGenerator(name = "seq_groups", sequenceName = "seq_groups", allocationSize = 1)
    @GeneratedValue(generator = "seq_groups", strategy = GenerationType.SEQUENCE)
    private Long id;
    
    @Column
    private String name; 
    
    @ManyToMany(mappedBy="groups")
    private List<SystemUser> users;

    public Groups() {
    }

    public Groups(Long id, String name, List<SystemUser> users) {
        this.id = id;
        this.name = name;
        this.users = users;
    }

    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<SystemUser> getUsers() {
        return users;
    }

    public void setUsers(List<SystemUser> users) {
        this.users = users;
    }
    
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 19 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Groups other = (Groups) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }


    @Override
    public String toString() {
        return "Groups{" + "id=" + id + ", name=" + name + ", users=" + users + '}';
    }

  

   
    
    
}
